/*analyses for Oneal and Tir's "Does the Diversionary Use of Force Threaten the
Democratic Peace," International Studies Quarterly, regarding major democracies:
4-7-2006*/

set mem 120m

use c:\growth\isqfinal\otdirect

desc
summ

/*make minimum value of caprat positive and generate square*/
replace lncaprat=lncaprat+10.3
gen lncapsq=lncaprat^2

/*make sure growth not measured across leaders*/
#del ;
sort state target year;
quietly by state target: gen grow_stldr=grow_st if (leadid_st==leadid_st[_n-1] &
      leadid_st==leadid_st[_n-2]);
quietly by state target: gen grow_tgtldr=grow_tgt if (leadid_tgt==leadid_tgt[_n-1] &
      leadid_tgt==leadid_tgt[_n-2]);
#del cr

gen logdist=ln(distance)

drop if depend>1

drop if grow_stldr==.
/*drop exactly zero growth b/c result of interpol of rgdppc*/
drop if grow_stldr==0

/*create control for number of states in system for non-rel dyads*/
gen systsize=-ln(numstate) if ~(dircont==1 | majpower==1)
replace systsize=0 if systsize==.

gen dyadid=(1000*state)+target

/*all dyads, fatal disputes in year t+1, originator + side A*/
#del ;

gen demXgrow=grow_stldr if democ_st_cg==1;
replace demXgrow=0 if demXgrow==. & grow_stldr~=.;

logit finitsda democ_st democ_tgt depend demXgrow lncaprat lncapsq allies dircont
      logdist majpower systsize pyfatA _spl*, nolog cluster(dyadid);  

/*GROWTH EFFECT FOR PROMINENT DEMOCRACIES*/
gen usgrowth=grow_stldr if state==2 & democ_st_cg==1;
replace usgrowth=0 if usgrowth==. & state~=2;

gen gbgrowth=grow_stldr if state==200 & democ_st_cg==1;
replace gbgrowth=0 if gbgrowth==. & state~=200;

gen isrgrowth=grow_stldr if state==666 & democ_st_cg==1;
replace isrgrowth=0 if isrgrowth==. & state~=666;

gen indgrowth=grow_stldr if state==750 & democ_st_cg==1;
replace indgrowth=0 if indgrowth==. & state~=750;

/*prominent democs as targets*/
gen ustgtgrow=grow_tgtldr if target==2 & democ_st_cg==1;
replace ustgtgrow=0 if ustgtgrow==. & target~=2;

gen gbtgtgrow=grow_tgtldr if target==200 & democ_st_cg==1;
replace gbtgtgrow=0 if gbtgtgrow==. & target~=200;

gen frtgtgrow=grow_tgtldr if target==220 & democ_st_cg==1;
replace frtgtgrow=0 if frtgtgrow==. & target~=220;

gen isrtgtgrow=grow_tgtldr if target==666 & democ_st_cg==1;
replace isrtgtgrow=0 if isrtgtgrow==. & target~=666;

gen indtgtgrow=grow_tgtldr if target==750 & democ_st_cg==1;
replace indtgtgrow=0 if indtgtgrow==. & target~=750;

/*include indicators only for prominent democs as initiators*/
gen us=1 if state==2;
replace us=0 if us==.;

gen gb=1 if state==200;
replace gb=0 if gb==.;

gen fr=1 if state==200;
replace fr=0 if fr==.;

gen israel=1 if state==666;
replace israel=0 if israel==.;

gen india=1 if state==750;
replace india=0 if india==.;

compress;

/*5 prominent democs, reported in text only*/
#del ;
logit finitsda democ_st democ_tgt depend usgrowth gbgrowth isrgrowth indgrowth
      lncaprat lncapsq allies dircont logdist us gb israel india majpower systsize
      pyfatA _spl*, nolog cluster(dyadid);

/*add growth of 5 democs when targets*/
logit finitsda democ_st democ_tgt depend usgrowth gbgrowth isrgrowth indgrowth
      ustgtgrow frtgtgrow gbtgtgrow isrtgtgrow indtgtgrow lncaprat lncapsq allies
      dircont logdist us gb fr israel india majpower systsize pyfatA _spl*, nolog
      cluster(dyadid);

exit;

